home *** CD-ROM | disk | FTP | other *** search
/ The 640 MEG Shareware Studio 2 / The 640 Meg Shareware Studio CD-ROM Volume II (Data Express)(1993).ISO / clang / warpcom.zip / WARPCOMM.DOC < prev    next >
Text File  |  1991-01-25  |  13KB  |  472 lines

  1.                     The Warp Communications Library
  2.  
  3.                               Version 1.02
  4.  
  5.                                 written
  6.  
  7.                                    by
  8.  
  9.                               Trevor Bell
  10.  
  11.                              Copyright 1991
  12.  
  13.  
  14. WHAT IT IS:
  15.  
  16.         The Warp Communications Library is a full-featured modem/serial
  17. communications library.  It can be used to create BBS doors, protocols,
  18. terminal programs, or actual BBS programs.  Currently the library only
  19. supports Turbo C and Turbo C++ with libraries for each however support
  20. for MSC is on the way and if you are a registered user with the source
  21. code then you could easily modify the source to work with any C
  22. compiler.
  23.  
  24.         Warp Comm is NOT PUBLIC DOMAIN, Warp Comm IS SHAREWARE.  A
  25. registration fee of $25 (of course I won't mind if you send more than
  26. $25) is required if you wish to use Warp Comm in any application to be
  27. distributed to the general public.  Registration will get you the full
  28. source code for both the Turbo C and Turbo C++ libraries and library files
  29. for each of the 6 memory models (tiny, small, medium, compact, large, huge).
  30. Without registration you will be limited to compiling programs in the small
  31. memory model and this will substantially limit programs.  By registering
  32. this program you will be contributing to the release of future versions
  33. of Warp Comm and future programs that I will be creating.  Your
  34. registration will be greatly appreciated.  See the file ORDER.FRM for
  35. details on registering.
  36.  
  37. Registrations may be sent to:
  38.  
  39.         Trevor Bell
  40.         P.O. Box 4173
  41.         Redondo Beach, CA  90278
  42.         Galleria Station
  43.  
  44. I can be contacted on THE SOURCE BBS at 213-371-3737.
  45.  
  46.  
  47. Two zip files are provided, one for Turbo C and Turbo C++ in standard
  48. C mode and one for Turbo C++ only in C++ mode.  They are:
  49.  
  50. TC.ZIP  (For C only)
  51. TCP.ZIP (For C++ only)
  52.  
  53.  
  54.  
  55. HOW TO USE IT:
  56.  
  57. --------------------------------------------------------------------------------
  58.  
  59.                For Turbo C++ and Turbo C users in C mode
  60.  
  61. --------------------------------------------------------------------------------
  62.  
  63. The file WARPCOMM.H must be included in any program wishing to use the
  64. Warp Comm library in TC, and the library file WCOMMS.LIB must be linked with
  65. the program.
  66.  
  67.  
  68. Opening the Com Port:
  69. ---------------------
  70.  
  71. open (baud_rate, interrupt_request, base_address,
  72.         receive_buffer_size, transmit_buffer_size);
  73.  
  74. baud_rate - the baud rate to open the com port at
  75.  
  76. interrupt request - which IRQ to open the comport at, usual values are
  77.         as follows:
  78.  
  79.         COM port 1: IRQ 4
  80.         COM port 2: IRQ 3
  81.  
  82.         all other COM ports are non-standard and would be machine
  83.         dependent.
  84.  
  85. base_address - which base address to use, common values are as follow:
  86.  
  87.         COM port 1: 0x3f8 (Hex)
  88.         COM port 2: 0x2f8 (Hex)
  89.  
  90. receive buffer size - this can vary with modem speed and the application
  91.         being used however, 2000 characters is usually a good place to start.
  92.  
  93. transmit buffer size - this can vary with modem speed and the application
  94.         being used however, 2000 characters is usually a good place to start.
  95.  
  96. Thus opening COM 1 at 2400 baud would work like this:
  97.  
  98.         com_open(2400, 4, 0x3F8, 2000, 2000);
  99.  
  100.  
  101. Outputting to the Com Port:
  102. ---------------------------
  103.  
  104. Outputting to the comport in TC is accomplished like this:
  105.  
  106. char value = 13;
  107. com_out_char(value);
  108.  
  109.  
  110. Inputting from the Com Port:
  111. ----------------------------
  112.  
  113. Inputting from the comport in TC is accomplished like this:
  114.  
  115. char value;
  116. value=com_get_char();
  117.  
  118.  
  119. Checking for a character waiting to be read:
  120. --------------------------------------------
  121.  
  122. Often it is necessary to know if there is a character waiting in the com
  123. port receive buffer, this can be checked with the char_waiting function
  124. which returns a 1 if there is a character or characters waiting, and a 0
  125. if the com port buffer is empty.  It is used like this:
  126.  
  127. char value;
  128.  
  129. if( char_waiting()) {
  130.     value=com_get_char();
  131. }
  132.  
  133.  
  134. Closing the Com Port:
  135. ---------------------
  136.  
  137. Closing out the com port is a simple task, it will disable com port
  138. interrupt routine, and free the memory allocated by the transmit and receive
  139. buffers.  It is used like this:
  140.  
  141. com_close();
  142.  
  143.  
  144. Sending a string to the Com Port:
  145. ---------------------------------
  146.  
  147. A null terminated string can be sent to the com port like this:
  148.  
  149. char *string="This is a null-terminated string.";
  150. com_out_char_str(string);
  151.  
  152. an alternate method of sending strings to the modem can also be used,
  153. like this:
  154.  
  155. send_modem_string("ATZ|");
  156.  
  157. where the | command represents a carriage return.
  158.  
  159.  
  160.  
  161. Sending a buffer to the Com Port:
  162. ---------------------------------
  163.  
  164. A buffer of a specified size can be sent to the com port like this:
  165.  
  166. unsigned char *buffer;
  167. unsigned int length=10;
  168. com_out_buf(buffer,length);
  169.  
  170.  
  171. Receiving a buffer from the Com Port:
  172. -------------------------------------
  173.  
  174. A buffer of a specified size can be received from the com port like this:
  175.  
  176. unsigned char *buffer;
  177. unsigned int length=10;
  178. com_get_buf(buffer,length);
  179.  
  180.  
  181. Setting the DTR pin of the modem:
  182. ---------------------------------
  183.  
  184. The DTR pin of the modem can be changed like this:
  185.  
  186. set_dtr(1);
  187.  
  188. A value of 1 will hold the DTR high, a value of 0 will hold it low
  189. causing most modems to hangup.
  190.  
  191.  
  192. Setting the RTS pin of the modem:
  193. ---------------------------------
  194.  
  195. The RTS pin of the modem can be changed like this:
  196.  
  197. set_rts(1);
  198.  
  199. A value of 1 will hold the RTS high allowing some modems to use hardware
  200. flow control (consult your modem manual on this), a value of 0 will
  201. hold it low.
  202.  
  203.  
  204. Clearing the transmit or receive buffers:
  205. -----------------------------------------
  206.  
  207. Clearing the transmit buffer will clear any characters waiting to be
  208. sent to the com port and is accomplished like this:
  209.  
  210. clear_xmit_buffer();
  211.  
  212. Clearing the receive buffer will clear any characters waiting to be
  213. received the com port and is accomplished like this:
  214.  
  215. clear_receive_buffer();
  216.  
  217.  
  218. Changing the baud rate:
  219. -----------------------
  220.  
  221. Changing the baud rate on the modem is accomplished like this:
  222.  
  223. set_baudrate(2400);
  224.  
  225.  
  226. Detecting a Carrier:
  227. --------------------
  228.  
  229. The carrier detect pin of the modem can be checked by examining the
  230. integer variable CD.  If CD is 1 then a carrier is present, if CD is 0
  231. then no carrier is present.  It can be used like this:
  232.  
  233. if(CD==1) {
  234.     puts("A carrier is detected.");
  235. }
  236.  
  237. --------------------------------------------------------------------------------
  238.  
  239.                       Turbo C++ users in C++ mode
  240.  
  241. --------------------------------------------------------------------------------
  242.  
  243. The file WARPCOMM.HPP must be included in any program wishing to use the
  244. Warp Comm library in TC++, and the library file WCOMMS.LIB must be linked with
  245. the program.  In the Turbo C++ versions of the library all the commands
  246. and most of the data structures are contained within the COM_port class,
  247. and thus must be accessed through the variable remote which is defined
  248. like this:
  249.  
  250. COM_port remote;
  251.  
  252. Opening the Com Port:
  253. ---------------------
  254.  
  255. remote.open (baud_rate, interrupt_request, base_address,
  256.         receive_buffer_size, transmit_buffer_size);
  257.  
  258. baud_rate - the baud rate to open the com port at
  259.  
  260. interrupt request - which IRQ to open the comport at, usual values are
  261.         as follows:
  262.  
  263.         COM port 1: IRQ 4
  264.         COM port 2: IRQ 3
  265.  
  266.         all other COM ports are non-standard and would be machine
  267.         dependent.
  268.  
  269. base_address - which base address to use, common values are as follow:
  270.  
  271.         COM port 1: 0x3f8 (Hex)
  272.         COM port 2: 0x2f8 (Hex)
  273.  
  274. receive buffer size - this can vary with modem speed and the application
  275.         being used however, 2000 characters is usually a good place to start.
  276.  
  277. transmit buffer size - this can vary with modem speed and the application
  278.         being used however, 2000 characters is usually a good place to start.
  279.  
  280. Thus opening COM 1 at 2400 baud would work like this:
  281.  
  282.         remote.open(2400, 4, 0x3F8, 2000, 2000);
  283.  
  284.  
  285. Outputting to the Com Port:
  286. ---------------------------
  287.  
  288. Outputting to the comport in TC++ is identical to file stream output,
  289. you simply use the overloaded bitshift operator with the variable to
  290. output to the port, like this:
  291.  
  292. char value = 13;
  293. remote << value;
  294.  
  295.  
  296. Inputting from the Com Port:
  297. ----------------------------
  298.  
  299. Inputting from the comport in TC++ is identical to file stream input,
  300. you simply use the overloaded bitshift operator with the variable to
  301. input from the port, like this:
  302.  
  303. char value;
  304. remote >> value;
  305.  
  306.  
  307. Checking for a character waiting to be read:
  308. --------------------------------------------
  309.  
  310. Often it is necessary to know if there is a character waiting in the com
  311. port receive buffer, this can be checked with the char_waiting function
  312. which returns a 1 if there is a character or characters waiting, and a 0
  313. if the com port buffer is empty.  It is used like this:
  314.  
  315. char value;
  316.  
  317. if( remote.char_waiting()) {
  318.     remote >> value;
  319. }
  320.  
  321.  
  322. Closing the Com Port:
  323. ---------------------
  324.  
  325. Closing out the com port is a simple task, it will disable com port
  326. interrupt routine, and free the memory allocated by the transmit and receive
  327. buffers.  It is used like this:
  328.  
  329. remote.close();
  330.  
  331.  
  332. Sending a string to the Com Port:
  333. ---------------------------------
  334.  
  335. A null terminated string can be sent to the com port like this:
  336.  
  337. char *string="This is a null-terminated string.";
  338. remote << string;
  339.  
  340. an alternate method of sending strings to the modem can also be used,
  341. like this:
  342.  
  343. remote.send_modem_string("ATZ|");
  344.  
  345. where the | command represents a carriage return.
  346.  
  347.  
  348. Sending a buffer to the Com Port:
  349. ---------------------------------
  350.  
  351. A buffer of a specified size can be sent to the com port like this:
  352.  
  353. unsigned char *buffer;
  354. unsigned int length=10;
  355. remote.out_buf(buffer,length);
  356.  
  357.  
  358. Receiving a buffer from the Com Port:
  359. -------------------------------------
  360.  
  361. A buffer of a specified size can be received from the com port like this:
  362.  
  363. unsigned char *buffer;
  364. unsigned int length=10;
  365. remote.get_buf(buffer,length);
  366.  
  367.  
  368. Setting the DTR pin of the modem:
  369. ---------------------------------
  370.  
  371. The DTR pin of the modem can be changed like this:
  372.  
  373. remote.set_dtr(1);
  374.  
  375. A value of 1 will hold the DTR high, a value of 0 will hold it low
  376. causing most modems to hangup.
  377.  
  378.  
  379. Setting the RTS pin of the modem:
  380. ---------------------------------
  381.  
  382. The RTS pin of the modem can be changed like this:
  383.  
  384. remote.set_rts(1);
  385.  
  386. A value of 1 will hold the RTS high allowing some modems to use hardware
  387. flow control (consult your modem manual on this), a value of 0 will
  388. hold it low.
  389.  
  390.  
  391. Clearing the transmit or receive buffers:
  392. -----------------------------------------
  393.  
  394. Clearing the transmit buffer will clear any characters waiting to be
  395. sent to the com port and is accomplished like this:
  396.  
  397. remote.clear_xmit_buffer();
  398.  
  399. Clearing the receive buffer will clear any characters waiting to be
  400. received the com port and is accomplished like this:
  401.  
  402. remote.clear_receive_buffer();
  403.  
  404.  
  405. Changing the baud rate:
  406. -----------------------
  407.  
  408. Changing the baud rate on the modem is accomplished like this:
  409.  
  410. remote.set_baudrate(2400);
  411.  
  412.  
  413. Detecting a Carrier:
  414. --------------------
  415.  
  416. The carrier detect pin of the modem can be checked by examining the
  417. integer variable CD.  If CD is 1 then a carrier is present, if CD is 0
  418. then no carrier is present.  It can be used like this:
  419.  
  420. if(remote.CD==1) {
  421.     puts("A carrier is detected.");
  422. }
  423.  
  424.  
  425. --------------------------------------------------------------------------------
  426.  
  427.                              CODE EXAMPLES
  428.  
  429. --------------------------------------------------------------------------------
  430.  
  431.  
  432. A very simple terminal program is provided with Warp Comm to demonstrate
  433. it's capabilities very minimally.  Feel free to modify it to your
  434. heart's desire, keep in mind however that without registration your
  435. program will need to remain within the small memory model.
  436.  
  437. The source code for this program is provided in the file TERM.C or
  438. TERM.CPP for TC and TC++.
  439.  
  440.  
  441.  
  442. --------------------------------------------------------------------------------
  443.  
  444.                                 SUPPORT
  445.  
  446. --------------------------------------------------------------------------------
  447.  
  448.  
  449. Support can be obtained through mail sent to my PO Box or by calling the
  450. following BBS:
  451.  
  452.         The Source
  453.         213-371-3737
  454.  
  455.  
  456. --------------------------------------------------------------------------------
  457.  
  458.                             VERSION HISTORY
  459.  
  460. --------------------------------------------------------------------------------
  461.  
  462.  
  463. Version 1.00:
  464.         not released to the public
  465.  
  466. Version 1.01:
  467.         My first release!
  468.  
  469. Version 1.02:
  470.         Fixed null pointer assignment.
  471.  
  472.